{#<!DOCTYPE html>#}
{#<html lang="en">#}
{#<head>#}
{#    <meta charset="UTF-8">#}
{#    <title>Title</title>#}
{#</head>#}
{#<body>#}
{#<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>#}
{#{% csrf_token %}#}
{# <p><a href="{% url 'assets_add' %}" type="button" class="btn btn-info">添加</a></p>#}
{#<table>#}
{#    <thead>#}
{#    <tr>#}
{#        <th>名称</th>#}
{#        <th>编号</th>#}
{#        <th>购买时间</th>#}
{#        <th>所属实验室</th>#}
{#        <th>操作</th>#}
{#    </tr>#}
{#    </thead>#}
{#    <tbody>#}
{#    {% for i in a %}#}
{#        <tr>#}
{#            <td>{{ i.name }}</td>#}
{#            <td>{{ i.ass_id }}</td>#}
{#            <td>{{ i.times|date:"Y-m-d H:i:s" }}</td>#}
{#            <td>#}
{#                {% for foo in i.assets_class.all %}#}
{#                    {{ foo.name }}#}
{#                {% endfor %}#}
{#            </td>#}
{#            <td><a value="{{ i.pk }}" url="{% url 'dele' 'assets' i.pk %}" type="button" class="a btn btn-danger">删除</a>#}
{#                <a href="{% url 'assets_e' i.pk %}" type="button" class="btn btn-info">编辑</a></td>#}
{#        </tr>#}
{#    {% endfor %}#}
{#    </tbody>#}
{#</table>#}
{##}
{#{% load static %}#}
{#<script src="{% static 'js/sweetalert.min.js' %}"></script>#}
{##}
{##}
{#<script>#}
{#    $('.a').click(function () {#}
{#        var b = $(this);#}
{#        swal({#}
{#            title: "警告",#}
{#            text: "删除后将无法恢复，需要继续吗？",#}
{#            icon: "warning",#}
{#            buttons: true,#}
{#            dangerMode: true,#}
{#        })#}
{#            .then((willDelete) => {#}
{#                if (willDelete) {#}
{#                    $.ajax({#}
{#                        url: $(this).attr('url'),#}
{#                        success: function (ret) {#}
{#                            if (ret.k === 'ok')#}
{#                                b.parent().parent().remove()#}
{#                        }#}
{#                    })#}
{#                    swal("删除成功！", {#}
{#                        icon: "success",#}
{#                    });#}
{#                } else {#}
{#                    swal("文件未删除");#}
{#                }#}
{#            });#}
{##}
{##}
{#    })#}
{##}
{##}
{#</script>#}
{##}
{##}
{#<script>#}
{#     $('.a').click(function () {#}
{#         var b = $(this);#}
{##}
{#         $.ajax({#}
{#             url:$(this).attr('url'),#}
{#             success:function (ret) {#}
{#                 if (ret.k==='ok')#}
{#                     b.parent().parent().remove()#}
{#             }#}
{#         })#}
{##}
{#     })#}
{# </script>#}
{#</body>#}
{#</html>#}















{% extends 'muban.html' %}


{% block lis %}

    {% csrf_token %}
    <h2 class="sub-header">资产</h2>
   <a href="{% url 'assets_add' %}" type="button" class="btn btn-info">添加</a>

    <div class="table-responsive">

    <table class="table table-striped">
            <thead>
    <tr>
        <th>名称</th>
        <th>编号</th>
        <th>购买时间</th>
        <th>所属实验室</th>
        <th>操作</th>
    </tr>
    </thead>
        <tbody>
    {% for i in a %}
        <tr>
            <td>{{ i.name }}</td>
            <td>{{ i.ass_id }}</td>
            <td>{{ i.times|date:"Y-m-d H:i:s" }}</td>
            <td>
                {% for foo in i.assets_class.all %}
                    {{ foo.name }}
                {% endfor %}
            </td>
            <td><a value="{{ i.pk }}" url="{% url 'dele' 'assets' i.pk %}" type="button" class="a btn btn-danger">删除</a>
                <a href="{% url 'assets_e' i.pk %}" type="button" class="btn btn-info">编辑</a></td>
        </tr>
    {% endfor %}
    </tbody>
    </table>


{% load static %}
<script src="{% static 'js/sweetalert.min.js' %}"></script>
<script src="{% static 'js/jquery.3.4.1.min.js' %}"></script>

    <script>
    $('.a').click(function () {
        var b = $(this);
        swal({
            title: "警告",
            text: "删除后将无法恢复，需要继续吗？",
            icon: "warning",
            buttons: true,
            dangerMode: true,
        })
            .then((willDelete) => {
                if (willDelete) {
                    $.ajax({
                        url: $(this).attr('url'),
                        success: function (ret) {
                            if (ret.k === 'ok')
                                b.parent().parent().remove()
                        }
                    })
                    swal("删除成功！", {
                        icon: "success",
                    });
                } else {
                    swal("文件未删除");
                }
            });


    })


</script>


{% endblock %}



{% block i1 %}
    class='active'
{% endblock %}







